package com.shop.loan.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.upms.helper.HyperModelCreatorVo;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Setter
@Getter
@Erupt(name = "首页设置", orderBy = "AppHomeSetting.bySort asc")
@Table(name = "s_app_home_setting")
@Entity
@ApiModel("首页图片")
public class AppHomeSetting extends HyperModelCreatorVo {

    @EruptField(
            views = @View(title = "名称"),
            edit = @Edit(title = "名称")
    )
    @ApiModelProperty(name = "name", value = "名称", dataType = "string", example = "1")
    private String name;

    @EruptField(
            views = @View(title = "图片"),
            edit = @Edit(title = "图片",
                    notNull = true,
                    type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE))
    )
    @ApiModelProperty(name = "logo", value = "图片", dataType = "string", example = "1")
    private String logo;


    @EruptField(
            views = @View(title = "跳转类型"),
            edit = @Edit(title = "跳转类型", type = EditType.CHOICE, search = @Search,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "分类", value = "classify"),
                                    @VL(label = "客服", value = "service"),
                                    @VL(label = "url", value = "url"),
                            })
            )
    )
    @ApiModelProperty(name = "jumpType", value = "跳转类型", dataType = "string", example = "1")
    private String jumpType;


    @ManyToOne
    @EruptField(
            views = @View(title = "跳转类目", column = "name"),
            edit = @Edit(title = "跳转类目",
                    type = EditType.REFERENCE_TREE,
                    desc = "请选择二级类目",
                    inputType = @InputType(type = "search"),
                    referenceTreeType = @ReferenceTreeType(
                            //如果不填，展示方式为列表
                            pid = "topClassify.id")
            )
    )
    @ApiModelProperty(name = "classify", value = "跳转类目", dataType = "string", example = "1")
    @JoinColumn(name = "classify_id")
    private Classify classify;

    @EruptField(
            views = @View(title = "跳转url"),
            edit = @Edit(title = "跳转url")
    )
    @ApiModelProperty(name = "jumpUrl", value = "跳转url", dataType = "string", example = "1")
    private String jumpUrl;

    @EruptField(
            views = @View(title = "首页位置"),
            edit = @Edit(title = "首页位置", notNull = true, type = EditType.CHOICE, search = @Search,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "轮播图", value = "banner"),
                                    @VL(label = "首页分类", value = "home_classify"),
                                    @VL(label = "广告图", value = "advertising"),
                            })
            )
    )
    @ApiModelProperty(name = "location", value = "首页位置   banner：轮播图  home_classify：首页分类   advertising：广告图", dataType = "string", example = "1")
    private String location;

    @EruptField(
            views = @View(title = "需要渠道显示"),
            edit = @Edit(
                    title = "需要渠道显示",
                    search = @Search,
                    type = EditType.BOOLEAN,
                    notNull = true
            )
    )
    private Boolean channelShow = false;

    @EruptField(
            views = @View(title = "排序"),
            edit = @Edit(title = "排序", desc = "数值大的在前")
    )
    @ApiModelProperty(name = "bySort", value = "排序", dataType = "string", example = "1")
    private Integer bySort;

    @EruptField(
            views = @View(title = "描述"),
            edit = @Edit(title = "描述")
    )
    @ApiModelProperty(name = "remark", value = "描述", dataType = "string", example = "1")
    private String remark;

}
